﻿//-----------------------------------------------------------------------
// <copyright file="AppConfMan.cs">
//     Copyright (c) BrowserGameFramework. All rights reserved.
// </copyright>
// <Autor>Wolf166 - BGF Framework</Autor>
//-----------------------------------------------------------------------

namespace BrowserGameFramework.Common.Configuration
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Configuration;

    /// <summary>
    /// This Class handels operations with the
    /// App.Conf or Web.Conf Configuration file.
    /// </summary>
    public static class AppConfMan
    {
        /// <summary>
        /// Gets the key as string.
        /// </summary>
        /// <param name="Key">The key witch should be read</param>
        /// <returns>The String</returns>
        public static string GetKeyAsString(string key)
        {
            return ConfigurationManager.AppSettings[key];
        }

        /// <summary>
        /// Gets the key as int.
        /// </summary>
        /// <param name="Key">The key.</param>
        /// <returns>integer value</returns>
        public static int GetKeyAsInt(string key)
        {
            int value = 0;
            int.TryParse(ConfigurationManager.AppSettings[key], out value);
            return value;
        }

        /// <summary>
        /// Gets the key as bool.
        /// </summary>
        /// <param name="Key">The key.</param>
        /// <returns>bool value</returns>
        public static bool GetKeyAsBool(string key)
        {
            bool result;
            bool.TryParse(ConfigurationManager.AppSettings[key],out result);
            
            return result;
        }
    }
}
